home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 16 / CU Amiga Magazine's Super CD-ROM 16 (1997-10-16)(EMAP Images)(GB)[!][issue 1997-11].iso / CUCD / Graphics / Ghostscript / source / gxistate.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  7.8 KB  |  217 lines

  1. /* Copyright (C) 1995, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gxistate.h */
  20. /* Imager state definition */
  21.  
  22. #ifndef gxistate_INCLUDED
  23. #  define gxistate_INCLUDED
  24.  
  25. #include "gscsel.h"
  26. #include "gsropt.h"
  27. #include "gxcvalue.h"
  28. #include "gxfixed.h"
  29. #include "gxline.h"
  30. #include "gxmatrix.h"
  31. #include "gxtmap.h"
  32.  
  33. /*
  34.  * Define the subset of the PostScript graphics state that the imager
  35.  * library API needs.  The definition of this subset is subject to change
  36.  * as we come to understand better the boundary between the imager and
  37.  * the interpreter.  In particular, the imager state currently INCLUDES
  38.  * the following:
  39.  *    line parameters: cap, join, miter limit, dash pattern
  40.  *    transformation matrix (CTM)
  41.  *    logical operation: RasterOp, transparency
  42.  *    color modification: alpha, rendering algorithm
  43.  *    overprint flag
  44.  *    rendering tweaks: flatness, fill adjustment, stroke adjust flag,
  45.  *      accurate curves flag
  46.  *    color rendering information:
  47.  *        halftone, halftone phases
  48.  *        transfer functions
  49.  *        black generation, undercolor removal
  50.  *        CIE rendering tables
  51.  *        halftone and pattern caches
  52.  * The imager state currently EXCLUDES the following:
  53.  *    graphics state stack
  54.  *    default CTM
  55.  *    path
  56.  *    clipping path
  57.  *    color specification: color, color space
  58.  *    font
  59.  *    device
  60.  *    caches for many of the above
  61.  */
  62.  
  63. /*
  64.  * Define the color rendering state information.
  65.  * This should be a separate object (or at least a substructure),
  66.  * but doing this would require editing too much code.
  67.  */
  68.  
  69. /* Opaque types referenced by the color rendering state. */
  70. #ifndef gs_halftone_DEFINED
  71. #  define gs_halftone_DEFINED
  72. typedef struct gs_halftone_s gs_halftone;
  73. #endif
  74. #ifndef gx_device_color_DEFINED
  75. #  define gx_device_color_DEFINED
  76. typedef struct gx_device_color_s gx_device_color;
  77. #endif
  78. #ifndef gx_device_halftone_DEFINED
  79. #  define gx_device_halftone_DEFINED
  80. typedef struct gx_device_halftone_s gx_device_halftone;
  81. #endif
  82.  
  83. /*
  84.  * We need some special memory management for the components of a
  85.  * c.r. state, as indicated by the following notations on the elements:
  86.  *    (RC) means the element is reference-counted.
  87.  *    (Shared) means the element is shared among an arbitrary number of
  88.  *      c.r. states and is never freed.
  89.  *    (Owned) means exactly one c.r. state references the element,
  90.  *      and it is guaranteed that no references to it will outlive
  91.  *      the c.r. state itself.
  92.  */
  93.  
  94. /* Define the interior structure of a transfer function. */
  95. typedef struct gx_transfer_colored_s {
  96.     /* The components must be in this order: */
  97.     gx_transfer_map *red;        /* (RC) */
  98.     gx_transfer_map *green;        /* (RC) */
  99.     gx_transfer_map *blue;        /* (RC) */
  100.     gx_transfer_map *gray;        /* (RC) */
  101. } gx_transfer_colored;
  102. typedef union gx_transfer_s {
  103.     gx_transfer_map *indexed[4];    /* (RC) */
  104.     gx_transfer_colored colored;
  105. } gx_transfer;
  106.  
  107. #define gs_color_rendering_state_common\
  108. \
  109.         /* Halftone screen: */\
  110. \
  111.     gs_halftone *halftone;            /* (RC) */\
  112.     gs_int_point screen_phase[gs_color_select_count];\
  113.         /* dev_ht depends on halftone and device resolution. */\
  114.     gx_device_halftone *dev_ht;        /* (Owned) */\
  115.         /* The contents of ht_cache depend on dev_ht. */\
  116.     struct gx_ht_cache_s *ht_cache;        /* (Shared) by all gstates */\
  117. \
  118.         /* Color (device-dependent): */\
  119. \
  120.     struct gs_cie_render_s *cie_render;    /* (RC) may be 0 */\
  121.     gx_transfer_map *black_generation;    /* (RC) may be 0 */\
  122.     gx_transfer_map *undercolor_removal;    /* (RC) may be 0 */\
  123.         /* set_transfer holds the transfer functions specified by */\
  124.         /* set[color]transfer; effective_transfer includes the */\
  125.         /* effects of overrides by TransferFunctions in halftone */\
  126.         /* dictionaries.  (In Level 1 systems, set_transfer and */\
  127.         /* effective_transfer are always the same.) */\
  128.     gx_transfer set_transfer;        /* members are (RC) */\
  129.     gx_transfer effective_transfer;        /* see below */\
  130. \
  131.         /* Color caches: */\
  132. \
  133.         /* cie_joint_caches depend on cie_render and */\
  134.         /* the color space. */\
  135.     struct gx_cie_joint_caches_s *cie_joint_caches;        /* (RC) */\
  136.         /* cmap_procs depend on the device's color_info. */\
  137.     const struct gx_color_map_procs_s *cmap_procs;        /* static */\
  138.         /* The contents of pattern_cache depend on the */\
  139.         /* the color space and the device's color_info and */\
  140.         /* resolution. */\
  141.     struct gx_pattern_cache_s *pattern_cache /* (Shared) by all gstates */
  142.  
  143. /*
  144.  * Enumerate the reference-counted pointers in a c.r. state.  Note that
  145.  * effective_transfer doesn't contribute to the reference count: it points
  146.  * either to the same objects as set_transfer, or to objects in a halftone
  147.  * structure that someone else worries about.
  148.  */
  149. #define gs_cr_state_do_rc_ptrs(m)\
  150.   m(halftone) m(cie_render) m(black_generation) m(undercolor_removal)\
  151.   m(set_transfer.colored.red) m(set_transfer.colored.green)\
  152.   m(set_transfer.colored.blue) m(set_transfer.colored.gray)\
  153.   m(cie_joint_caches)
  154.  
  155. /* Enumerate the pointers in a c.r. state. */
  156. #define gs_cr_state_do_ptrs(m)\
  157.   m(0,halftone) m(1,dev_ht) m(2,ht_cache)\
  158.   m(3,cie_render) m(4,black_generation) m(5,undercolor_removal)\
  159.   m(6,set_transfer.colored.red) m(7,set_transfer.colored.green)\
  160.   m(8,set_transfer.colored.blue) m(9,set_transfer.colored.gray)\
  161.   m(10,effective_transfer.colored.red) m(11,effective_transfer.colored.green)\
  162.   m(12,effective_transfer.colored.blue) m(13,effective_transfer.colored.gray)\
  163.   m(14,cie_joint_caches) m(15,pattern_cache)
  164. #define st_cr_state_num_ptrs 16
  165.  
  166. /* Define the imager state structure itself. */
  167. #define gs_imager_state_common\
  168.     gs_memory_t *memory;\
  169.     gx_line_params line_params;\
  170.     gs_matrix_fixed ctm;\
  171.     gs_logical_operation_t log_op;\
  172.     gx_color_value alpha;\
  173.     bool overprint;\
  174.     float flatness;\
  175.     gs_fixed_point fill_adjust;    /* fattening for fill */\
  176.     bool stroke_adjust;\
  177.     bool accurate_curves;\
  178.     gs_color_rendering_state_common
  179. #define st_imager_state_num_ptrs\
  180.   (st_line_params_num_ptrs + st_cr_state_num_ptrs)
  181. /* Access macros */
  182. #define ctm_only(pis) (*(const gs_matrix *)&(pis)->ctm)
  183. #define ctm_only_writable(pis) (*(gs_matrix *)&(pis)->ctm)
  184. #define set_ctm_only(pis, mat) (*(gs_matrix *)&(pis)->ctm = (mat))
  185. #define gs_init_rop(pis) ((pis)->log_op = lop_default)
  186. #define gs_currentlineparams_inline(pis) (&(pis)->line_params)
  187.  
  188. #ifndef gs_imager_state_DEFINED
  189. #  define gs_imager_state_DEFINED
  190. typedef struct gs_imager_state_s gs_imager_state;
  191. #endif
  192.  
  193. struct gs_imager_state_s {
  194.     gs_imager_state_common;
  195. };
  196.  
  197. /* Initialization for gs_imager_state */
  198. #define gs_imager_state_initial(scale)\
  199.   0, { gx_line_params_initial },\
  200.    { scale, 0.0, 0.0, -(scale), 0.0, 0.0 },\
  201.   lop_default, gx_max_color_value, 0/*false*/, 1.0,\
  202.    { fixed_half, fixed_half }, 0/*false*/, 0/*false*/
  203.  
  204. #define private_st_imager_state()    /* in gsstate.c */\
  205.   gs_private_st_composite(st_imager_state, gs_imager_state, "gs_imager_state",\
  206.     imager_state_enum_ptrs, imager_state_reloc_ptrs)
  207.  
  208. /* Initialize an imager state, other than the parts covered by */
  209. /* gs_imager_state_initial. */
  210. /* The halftone, dev_ht, and ht_cache elements are not set or used. */
  211. int gs_imager_state_initialize(P2(gs_imager_state *pis, gs_memory_t *mem));
  212.  
  213. /* Release an imager state. */
  214. void gs_imager_state_release(P1(gs_imager_state *pis));
  215.  
  216. #endif                    /* gxistate_INCLUDED */
  217.